package StudyCode.summary.myfile;

import java.io.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CopyOneStreamToAnotherStream {
	public static void main(String[] args) throws FileNotFoundException {
		copyStream(new FileInputStream("E:\\迅雷下载\\test1.txt"), new FileOutputStream("E:\\Copy\\test1.txt"));
	}

	private static void copyStream(InputStream in, OutputStream out) {
		try {
			byte[] buffer = new byte[4096];
			int len;
			while ((len = in.read(buffer)) >= 0) {
				out.write(buffer, 0, len);
			}
			System.out.println("复制成功。");
			out.close();
			in.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
